package com.bj58.mis.apm.server.logreceiver.controller;

import com.bj58.mis.apm.server.core.common.result.Page;
import com.bj58.mis.apm.server.core.common.result.ResultBean;
import com.bj58.mis.apm.server.logreceiver.dto.ApmLog;
import com.bj58.mis.apm.server.logreceiver.query.ApmlogQuery;
import com.bj58.mis.apm.server.logreceiver.service.ApmLogService;
import com.bj58.mis.apm.server.logreceiver.query.PageInfo;
import com.bj58.mis.apm.server.logreceiver.vo.ApmLogVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/log")
public class ApmLogController {

	@Autowired
	private ApmLogService service;

	@PostMapping(path="", consumes=MediaType.APPLICATION_JSON_UTF8_VALUE)
	public ResultBean insert(@RequestBody ApmLog log){
		//System.out.println("logEntity:" + log.toString());
		service.save(log);
		return ResultBean.success(null, "上报日志成功!");
	}

	@RequestMapping("/queryPage")
	public ResultBean<Page<ApmLogVO>> queryPage(@ModelAttribute ApmlogQuery apmlogQuery, @ModelAttribute PageInfo pageInfo) {
		return ResultBean.success(service.queryPage(apmlogQuery, pageInfo));
	}
}
